import http from '@/http/index'


export async function create(params: any) {
  const res = await http({
    method: 'POST',
    path: '/api/menus',
    params,
  })
  return res
}
export async function update(params: any) {
  const res = await http({
    method: 'PUT',
    path: '/api/menus',
    params,
  })
  return res
}
export async function findAll() {
  const res = await http({
    method: 'GET',
    path: '/api/menus',
    params: {}
  })
  return res
  /**
   * 根据ID查找菜单项
   *
   * @returns 返回查找到的菜单项数据
   */
} export async function findById(menuId: number) {
  const res = await http({
    method: 'GET',
    path: '/api/menus/' + menuId,
    params: {}
  })
  return res
}
export async function findByRoleId(role_id: number) {
  const res = await http({
    method: 'GET',
    path: '/api/menus/by_role_id',
    params: {
      role_id
    }
  })
  return res
}

export async function findTree() {
  const res = await http({
    method: 'GET',
    path: '/api/menus/by_tree',
    params: {}
  })
  return res
}
